package com.example.baseexercises.Redis;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 辛之所想
 * @create: 2025-11-15 20:42
 * @description:
 **/
@RestController
@RequestMapping("/redisSet")
@Tag(name = "RedisSet",description = "RedisSet操作")
public class RedisSet {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/redisSetTest")
    @Operation(summary = "RedisSet测试")
    public String redisSetTest() {
        set("redisSet", "redisSet");
        return get("redisSet");
    }
    public void set(String key, String value) {
        stringRedisTemplate.opsForSet().add(key, value);
    }

    public String get(String key) {
        return stringRedisTemplate.opsForSet().pop(key);
    }
}
